window.addEvent("domready",function(){
	
	Fx.Height = Fx.Style.extend({initialize: function(el, options){this.parent(el, 'height', options);this.element.setStyle('overflow', 'hidden');},toggle: function(){return (this.element.offsetHeight > 0) ? this.custom(this.element.offsetHeight, 0) : this.custom(0, this.element.scrollHeight);},show: function(){return this.set(this.element.scrollHeight);}});
	
	/*if($('horiznav')){
		$('horiznav').setStyle("width",($('horiznav').getSize().size.x+"px")); 
		$('horiznav').setStyle("float","none");
		$('horiznav').setStyle("margin","0 auto");
		$('horiznav').setStyle("top",$('horiznav').getPosition().getTop + "px");
		$('horiznav').setStyle("left",$('horiznav').getPosition().getLeft + "px");
		$('horiznav').setStyle("position","absolute");
	}*/
	
	if($('stylearea')){
		$('st_icon-1').setStyle("display","block");
		$('st_icon-2').setStyle("display","block");
	
		var efx1 = new Fx.Opacity('st_icon-1');
		var efx2 = new Fx.Opacity('st_icon-2');
		var ix = 0; 
		efx1.hide();
		efx2.hide();
	
		$A($$('.style_switcher')).each(function(element,index){
			if(index !== 0){
				element.addEvent('click',function(event){
					var event = new Event(event);
					event.preventDefault();
					changeStyle(index);
				});
			}
			else{
				element.addEvent('click',function(event){
					var event = new Event(event);
					event.preventDefault();
				
					if(ix%2 == 0){
						efx1.toggle();
						(function(){efx2.toggle();}).delay(250);
					}
					else{
						efx2.toggle();
						(function(){efx1.toggle();}).delay(250);
					}
					ix++;
				});
			}
		});
		template_path = gk8_path;
		new SmoothScroll();
	}
	
	$$("#jwscroller-inner img").setStyle("border","none");
	
if($('slide_area_container')){
	var login = false;
	var search = false
	
	if($('slide_area_login')) var login_area = $('slide_area_login');
	if($('slide_area_search')) var search_area = $('slide_area_search');
	if($('slide_area_search')) var cont = $('slide_area');
	
	cont.setProperty("class","pa-1");
	if($('slide_area_login')) $('slide_area_login').setStyle('display','none');
	$('slide_area_search').setStyle('display','none');
	
	var fxx = new Fx.Height('slide_area_container',{duration: 300,transition: Fx.Transitions.linear});
	
	fxx.set(0);
	
	if($("search_trigger")){
	$("search_trigger").addEvent("click",function(){
		if(search){
			search = false;
			(function(){search_area.setStyle('display','none');}).delay(300);
			fxx.toggle();
		}
		else if(login){
			fxx.toggle();
			login = false;
			search = true;
			(function(){
				cont.setProperty("class","pa-2");
				if($('slide_area_login')) login_area.setStyle('display','none');
				search_area.setStyle('display','block');
				fxx.toggle();
			}).delay(400);
		}
		else if(!(login || search)){
			search = true;
			cont.setProperty("class","pa-2");
			search_area.setStyle('display','block');
			fxx.toggle();
		}			
	});
	}
	
	if($("login_trigger")){
	$("login_trigger").addEvent("click",function(){
		if(login){
			login = false;
			(function(){login_area.setStyle('display','none');}).delay(300);
			fxx.toggle();
		}
		else if(search){
			fxx.toggle();
			login = true;
			search = false;
			(function(){
				cont.setProperty("class","pa-1");
				login_area.setStyle('display','block');
				if($('slide_area_search')) search_area.setStyle('display','none');
				fxx.toggle();
			}).delay(400);
		}
		else if(!(login || search)){
			cont.setProperty("class","pa-1");
			login = true;
			login_area.setStyle('display','block');
			fxx.toggle();
		}		
	});
	}
}
	
	var modwmt = $('page').getElementsBySelector('div[class^=moduletable]');
	
	modwmt.forEach(function(el){
		if(el.getElements("h3").length > 0){
			var c = el.getElement("h3").innerHTML;
			el.getElement("h3").innerHTML = '<span>' + c + '</span>';
		}
	});
});

function changeStyle(style){
	var file = template_path+'css/style'+style+'.css';
	new Asset.css(file);
	new Cookie.set('gk8_temp_style',style,{duration: 200,path: "/"});
	actual_style = style;
}